import os import subprocess from phue import Bridge from tkinter import * from itertools import cycle from rgbxy import Converter import tkinter.colorchooser bridge_physical_address = '00-17-88-2e-07-79' ipSearch = str(subprocess.check_output("arp -a")) print(ipSearch) print(" ") print(" ") print(" ") ipLocation = ipSearch.find(bridge_physical_address) print("IP Location in network list is:", ipLocation) ipStartLoc = (ipLocation - 22) ipEndLoc = (ipLocation - 10) ip = ipSearch[ipStartLoc:ipEndLoc] print("Bridge ip is:", ip) b = Bridge(ip) b.connect() b.create_group('Oscar', [1,2]) window = Tk() window.title("Philip Hue Light Controls") window.configure(background="#4A4A4A") window.minsize(150, 100) converter = Converter() def click1(): b.set_light(['BIG BOI'], 'on', True) def click2(): b.set_light(['BIG BOI'], 'on', False) def click3(): b.set_light(['Smol boi'], 'on', True) def click4(): b.set_light(['Smol boi'], 'on', False) def click5(): b.set_group(['Oscar'], 'on', True) def click6(): b.set_group(['Oscar'], 'on', False) def click7(): colour = tkinter.colorchooser.askcolor() colour = colour[1].lstrip('#') xy = converter.hex_to_xy(colour) print("Changing Colour to", colour) b.set_group('Oscar', 'xy', xy) def click8(): scaleW = Tk() scaleW.title("Philip Hue brightness Controls") scaleW.configure(background="#4A4A4A") scaleW.minsize(300, 20) def scaleevent(v): global variable print(v) variable = v def savevalue(): brightness = int(variable) b.set_group('Oscar', 'bri', brightness) Scale(scaleW, orient='horizontal', from_=0, to=254, command=scaleevent, width=20, length=300).grid(column=0,row=0) Button(scaleW, text="Okay", command=savevalue).grid(column=1, row=0) scaleW.mainloop() b.set_group('Oscar', 'bri', 254) def click9(): b.set_group('Oscar', 'bri', 254) Button (window, text="Big Boi on",font="none 20 bold", bg="#F738D7", command=click1, height = 5, width = 15) .grid(row=0, column=0) Button (window, text="Big Boi off", font="none 20 bold", bg="#F738D7", command=click2, height = 5, width = 15) .grid(row=1, column=0, sticky=N) Button (window, text="Smol boi on", font="none 20 bold", bg="#F738D7", command=click3, height = 5, width = 15) .grid(row=0, column=1, sticky=N) Button (window, text="Smol boi off", font="none 20 bold", bg="#F738D7", command=click4, height = 5, width = 15) .grid(row=1, column=1, sticky=N) Button (window, text="Both on", font="none 20 bold", bg="#F738D7", command=click5, height = 5, width = 15) .grid(row=0, column=2, sticky=N) Button (window, text="Both off", font="none 20 bold", bg="#F738D7", command=click6, height = 5, width = 15) .grid(row=1, column=2, sticky=N) Button (window, text="Select colour", font="none 20 bold", bg="#F738D7", command=click7, height = 5, width = 15) .grid(row=2, column=1, sticky=N) Button (window, text="Change Brightness", font="none 20 bold", bg="#F738D7", command=click8, height = 5, width = 15) .grid(row=2, column=0, sticky=N) Button (window, text="Brightness to 100%", font="none 20 bold", bg="#F738D7", command=click9, height = 5, width = 15) .grid(row=2, column=2, sticky=N) window.mainloop()